package com.xiaoxi.iteratormode;

import com.xiaoxi.iteratormode.core.Iterator;
import com.xiaoxi.iteratormode.core.aggregate.BookSelf;
import com.xiaoxi.iteratormode.core.domain.Book;

import java.util.HashMap;

/**
 * @Author xiaoxi
 * @ProjectName design_mode
 * @PackageName com.xiaoxi.iteratormode
 * @ClassName Main
 * @Description TODO
 * @Date 2023/3/7 10:36
 * @Version 1.0
 */
public class Main {
    public static void main(String[] args) {
        System.out.println("迭代器模式开始");

        BookSelf bookSelf = new BookSelf(10);
        Book book1 = new Book("设计模式从入门与放弃");
        Book book2 = new Book("萧兮设计模式");
        bookSelf.appendBook(book1);
        bookSelf.appendBook(book2);
        Iterator iterator = bookSelf.iterator();

        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }

        while (iterator.hasPrevious()) {
            System.out.println(iterator.previous());
        }


        System.out.println("迭代器模式结束");
    }
}
